/*
 * @Author: aggfb 714740235@qq.com
 * @Date: 2024-04-16 22:44:09
 * @LastEditors: aggfb 714740235@qq.com
 * @LastEditTime: 2024-04-17 23:07:04
 * @FilePath: \stepper_motor\bsp\bsp_exit.c
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include "bsp_exit.h"

/**
 * 外部中断初始化
*/
void bsp_exit_init(void)
{
    rcu_periph_clock_enable(RCU_GPIOA);
    rcu_periph_clock_enable(RCU_AF);

    gpio_init(PORT_DIR_MOTOR,   GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, PIN_DIR_MOTOR);
    gpio_init(PORT_START_MOTOR, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, PIN_START_MOTOR);

    nvic_irq_enable(EXTI5_9_IRQn, 2U, 0U);
    
    gpio_exti_source_select(GPIO_PORT_SOURCE_GPIOA, GPIO_PIN_SOURCE_6);
    exti_init(EXTI_6, EXTI_INTERRUPT, EXTI_TRIG_FALLING);
    exti_interrupt_flag_clear(EXTI_6);

    gpio_exti_source_select(GPIO_PORT_SOURCE_GPIOA, GPIO_PIN_SOURCE_8);
    exti_init(EXTI_8, EXTI_INTERRUPT, EXTI_TRIG_FALLING);
    exti_interrupt_flag_clear(EXTI_8);
}
